<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="menu" content="mainMenu" />
<meta name="nav" content="0" />
<meta name="acc" content="5" />
<title>监督组管理</title>
<script src="${ctx}/scripts/plugin/jquery.multiselect.min.js"
	type="text/javascript"></script>
<link href="${ctx}/styles/lightness/jquery-ui-1.8.12.custom.css"
	rel="stylesheet" />
<script>
	function areacheck() {
		var atv = $("a#area  input").val();
		var reg = new RegExp(/[(^请选择)]/);
		if (atv.search(reg) == -1) {
			$("#msg").hide();
			return true;
		} else {
			$("#msg").show();
		}
		return false;
	};
	$(document).ready(function() {
		//聚焦第一个输入框
		$("#name").focus();
		$("#area").multiSelect({
			minWidth : 400,
			selectedList : 5
		});

		$("#inputForm").validate({
			"name" : "required"
		});
		
		 $("#msg").hide();
		 $("#sub").bind('click',areacheck);
		 $("#area").bind('click',areacheck);
	});

	function addSupervisor(sorId) {
		var url = '${ctx}/app/supervisor!input.action?superviseGroupId=${id}&id='
				+ sorId;
		mm = showDialogWindow(url);
		if (mm) {
			window.location.reload();
		}
	}
	function deleteSupervisor(sorId) {
		var url = '${ctx}/app/supervisor!delete.action?id=' + sorId;
		$.ajax({
			url : url,
			success : function(msg) {
				if ("1" == msg) {
					alert("成功删除监督人员！");
					location.reload();
				} else {
					alert("删除监督人员失败！");
				}
			}
		});
	}
</script>
</head>

<body>
	<form action="${ctx}/app/supervise!save.action" method="post"
		id="inputForm" class='yform'>
		<input type="hidden" name="id" value="${id}" />
		<div id="caption">
			<h6>
				<s:if test="id == null">创建</s:if>
				<s:else>修改</s:else>
				监督组
			</h6>
		</div>
		<div id="content">
			<table class="formtable">
				<tr>
					<td>监督组名称:</td>
					<td><input type="text" id="name" name="name" size="40"
						value="${name}" class="required" /></td>
				</tr>
				<tr>
					<td>职责:</td>
					<td><input type="text" id="duty" name="duty" size="40"
						value="${duty}" /></td>
				</tr>
				<tr>
					<td>负责片区:</td>
					<td colspan="3"><pt:code category="4419"  name="area"
							default="${area}" multiple="multiple"></pt:code>
					<div id="msg" style="display:none;" ><font color="red" style="font-family: 黑体">请选择所在地区 </font> </div>
					</td>
				</tr>
				<tr>
					<td>负责人:</td>
					<td><input type="text" id="principal" name="principal"
						size="40" value="${principal}" /></td>
				</tr>
				<tr>
					<td>备 注:</td>
					<td><input type="text" id="remark" name="remark" size="40"
						value="${remark}" /></td>
				</tr>
			</table>
			<c:if test="${not empty id }">
				<fieldset>
					<legend>成员列表</legend>
					<table class="formtable">
						<tr>
							<th>姓名</th>
							<th>电话</th>
							<th>职责</th>
							<th>操作</th>
						</tr>
						<c:forEach items="${supervisorList}" var="sor" varStatus="soo">
							<tr>
								<td><a href="#" onclick="addSupervisor('${sor.id}');">${sor.officer.name}</a>&nbsp;
								</td>
								<td>${sor.phone}</td>
								<td><pt:code category="3066" code="${sor.duty }"></pt:code></td>
								<td><a href="#" onclick="addSupervisor('${sor.id}');">修改</a>
									<a href="#" onclick="deleteSupervisor('${sor.id}');">删除</a></td>
							</tr>
						</c:forEach>
						<tr>
							<td align="right" colspan="4"><input type="button"
								class="reset" value="添加监督成员 " onclick="addSupervisor();" /></td>
						</tr>
					</table>
				</fieldset>
			</c:if>
		</div>
		<div class="type-button">
			<input type="submit" id="sub" value="提交" />&nbsp; <input type="button"
				value="返回" class="reset"
				onclick="window.location.href='${ctx}/app/supervise.action';" />
		</div>
	</form>
</body>
</html>
